#define _CRT_SECURE_NO_WARNINGS 1
#include "SmartPtr.h"
using namespace std;
void testSmartPtr1()
{
	SmartPtr<pair<string, int>> sp1(new pair<string, int>("ljt", 9));
	sp1->first += '6';
	sp1->second += 2;
	cout << sp1->first << ' ' << sp1->second << endl;

	SmartPtr<int> sp2(new int);
	*sp2 = 10;
	cout << *sp2 << endl;
}

void testSharedPtr1()
{
	ljt::shared_ptr<string> s1(new string("yyyyyyyyyy"));
	ljt::shared_ptr<string> s2 = s1;
	ljt::shared_ptr<string> s3(new string("xxxx"));

	s3 = s3;

	s3 = s1;

	cout << *s1 << endl;

	cout << *s3 << endl;
}
struct ListNode
{
	int val;
	ljt::weak_ptr<ListNode> next;
	ljt::weak_ptr<ListNode> prev;


};
void testSharedPtr2()
{
	ljt::shared_ptr<ListNode> n1(new ListNode);
	ljt::shared_ptr<ListNode> n2(new ListNode);
	n1->val = 1;
	n2->val = 2;

	n1->next = n2;
	n2->prev = n1;

	cout << n1.count() << endl;
	cout << n2.count() << endl;
}

void testSharedPtr3()
{
	//ljt::shared_ptr<ListNode> sp1(new ListNode[10], DelArray<ListNode>());
	ljt::shared_ptr<ListNode> sp2(new ListNode[10], [](ListNode* ptr) {delete[] ptr; });
	ljt::shared_ptr<FILE> sp3(fopen("Test.cpp", "r"), [](FILE* ptr) {fclose(ptr); });

	ljt::shared_ptr<ListNode> sp4(new ListNode);
}
int main()
{
	testSharedPtr3();
	return 0;
}